package com.leyou.item.api;

import com.leyou.common.vo.PageResult;
import com.leyou.item.pojo.Sku;
import com.leyou.item.pojo.Spu;
import com.leyou.item.pojo.SpuDetail;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

public interface GoodsApi {
     /**
     * 根据spuid查询spu详情
     *
     * @param spuId
     * @return
     */
    @GetMapping("/spu/detail/{id}")
    SpuDetail querySpuDetailById(@PathVariable("id") Long spuId);

    /**
     * 根据spuid查询所有sku
     *
     * @param spuId
     * @return
     */
    @GetMapping("/sku/list")
    List<Sku> querySkuBySpuId(@RequestParam("id") Long spuId);

    /**
     * 分页查询spu
     *
     * @param page
     * @param rows
     * @param saleable
     * @param key
     * @return
     */
    @GetMapping("/spu/page")
    PageResult<Spu> querySpuByPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,//当前页
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,//每页条数
            @RequestParam(value = "saleable", required = false) Boolean saleable,//过滤条件是否上下架
            @RequestParam(value = "key", required = false) String key//搜索条件
    );

    /**
     * id查询spu
     * @param id
     * @return
     */
    @GetMapping("spu/{id}")
     Spu querySpuById(@PathVariable("id") Long id);


    @GetMapping("sku/{skuId}")
     Sku querySkuById(@PathVariable("skuId") Long skuId);
}
